package com.cskaoyan.controller.promotion_controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.Coupon;
import com.cskaoyan.bean.bo.CouponCreateBO;
import com.cskaoyan.bean.bo.CouponDeleteBO;
import com.cskaoyan.bean.params.BaseParam;
import com.cskaoyan.bean.vo.promotion_vo.CouponCreateVO;
import com.cskaoyan.bean.vo.promotion_vo.CouponListUserVO;
import com.cskaoyan.bean.vo.promotion_vo.CouponListVO;
import com.cskaoyan.service.promotion_service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description：
 * @author: 曹旭
 * @date: 2022/5/7 15:24
 */
@RestController
@RequestMapping("admin/coupon")
public class CouponController {
    @Autowired
    CouponService couponService;

    @RequestMapping("list")
    public BaseRespVo list(BaseParam baseParam, Coupon coupon){
        CouponListVO couponListVO = couponService.list(baseParam, coupon);
        return BaseRespVo.ok(couponListVO);
    }

    @RequestMapping("create")
    public BaseRespVo createCoupon(@RequestBody CouponCreateBO couponCreateBO) {
        System.out.println("couponCreateBO = " + couponCreateBO);
        CouponCreateVO couponCreateVO = couponService.createCoupon(couponCreateBO);
        return BaseRespVo.ok(couponCreateVO);
    }

    @RequestMapping("update")
    public BaseRespVo updateCoupon(@RequestBody Coupon coupon) {
        Coupon coupon1 = couponService.updateCoupon(coupon);
        return BaseRespVo.ok(coupon1);

    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody CouponDeleteBO coupon) {
        couponService.deleteCoupon(coupon);
        return BaseRespVo.out();
    }

    @RequestMapping("listuser")
    public BaseRespVo CouponListUser(BaseParam param,Integer couponId,Integer userId,Short status) {

        CouponListUserVO listUserVO = couponService.couponListUser(param, couponId, userId, status);
        return BaseRespVo.ok(listUserVO);
    }
}
